package com.sptpc.demo1.support;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.joda.money.Money;
import org.springframework.boot.jackson.JsonComponent;
import java.io.IOException;


@JsonComponent
public class MoneySerializer extends StdSerializer<Money> {

    protected MoneySerializer() {
        super(Money.class);
    }


    @Override
    public  void  serialize(Money money,
                            JsonGenerator jsonGenerator,
                            SerializerProvider SerializerProvider)
           throws IOException{
        jsonGenerator.writeNumber(money.getAmount());
    }
}
